﻿
//测试程序主入口


#include <stdio.h>
#include "myVector.h"
#include "myRBMap.h"
#include "myTools.h"


int main(){
	
	
	printf("algorithm main start...\n");
	printDataStructSize();
	/*
	PRINTDATASIZE(myVector);
	printf("CLOCKS_PER_SEC:%d\n",CLOCKS_PER_SEC);
	
	TESTTIME_BEGIN(初始化)
	//测试大数组初始化用时
	myVector* vec0 = createMyVector(10000000);
	int i = 0;
	for(i = 0; i < 15000000;i++){
		myVectorNode item;
		item.testValue = i * 100;
		item.bindDataPtr = myRandInt(0,0xffff);
		myVectorAppendItem(vec0,&item);
	}
	
	
	myVector* vec1 = createMyVector(10000000);
	for(i = 0; i < 20000000;i++){
		myVectorNode item;
		item.testValue = i * 10;
		item.bindDataPtr = myRandInt(0,0xffff);
		myVectorAppendItem(vec1,&item);
	}
	
	TESTTIME_END
	
	TESTTIME_BEGIN(大数组前部插入数据)
	//myVectorTestPrint(vec0);
	
	myVectorNode item;
	//往大数组前部插入数据用时
	item.testValue = 911;
	myVectorInsertItemAt(vec0,&item,3);
	myVectorPrintAt(vec0,22);
	//item.testValue = 120;
	//myVectorInsertItemAt(vec0,&item,3);
	TESTTIME_END
	
	MYASSERT(4 > 66);        //断言测试
	
	TESTTIME_BEGIN(删除大数组前部的数据)
	//删除大数组前部的数据用时
	myVectorRemoveItemAt(vec0,4);
	TESTTIME_END
	
	TESTTIME_BEGIN(大数组追加一个元素)
	//给大数组追加一个元素
	item.testValue = 911;
	myVectorAppendItem(vec0,&item);
	TESTTIME_END
	
	TESTTIME_BEGIN(两个大数组连接)
	//测试两个大数组连接时间
	myVectorAppendVector(vec0,vec1);
	
	TESTTIME_END
	
	
	myVector* catVec1 = createMyVector(10);
	for(i = 0; i < 6;i++){
		myVectorNode item;
		item.testValue = i*20 + 5;
		item.bindDataPtr = myRandInt(0,0xffff);
		myVectorAppendItem(catVec1,&item);
	}
	
	myVector* catVec2 = createMyVector(10);
	for(i = 0; i < 7;i++){
		myVectorNode item;
		item.testValue = i*50;
		item.bindDataPtr = myRandInt(0,0xffff);
		myVectorAppendItem(catVec2,&item);
	}
	
	myVectorTestPrint(catVec1);
	myVectorTestPrint(catVec2);
	myVectorAppendVector(catVec1,catVec2);
	myVectorTestPrint(catVec1);
	myVectorTestPrint(catVec2);
	
	myVectorSwap(catVec2,1,3);
	myVectorRemoveItemAt(catVec2,5);
	myVectorTestPrint(catVec2);
	
	
	
	releaseMyVector(vec0);
	releaseMyVector(vec1);
	releaseMyVector(catVec1);
	releaseMyVector(catVec2);
	
	
	
	printf("rand:%d\n",rand());
	printf("myRandFloatOne:%f\n",myRandFloatOne);
	printf("myRandInt:%d\n",myRandInt(4,8));
	printf("myRandFloat:%f\n",myRandFloat(10,20));
	*/
	
	//map测试
	myRBMap* testMap0 = createMyRBMap();
	
	myRBMapNode n0 = getNullNode(18,18);
	myRBMapNode n1 = getNullNode(19,19);
	myRBMapNode n2 = getNullNode(20,20);
	myRBMapNode n3 = getNullNode(21,21);
	myRBMapNode n4 = getNullNode(22,22);
	myRBMapNode n5 = getNullNode(22,22);
	myRBMapNode n6 = getNullNode(17,17);
	myRBMapNode n7 = getNullNode(16,16);
	myRBMapNode n8 = getNullNode(15,15);
	myRBMapNode n9 = getNullNode(10,10);
	myRBMapNode n10 = getNullNode(1,1);
	myRBMapNode n11 = getNullNode(2,2);
	myRBMapAddItem(testMap0,&n0);
	printMyRBMapMidOrder(testMap0);
	myRBMapAddItem(testMap0,&n1);
	printMyRBMapMidOrder(testMap0);
	myRBMapAddItem(testMap0,&n2);
	printMyRBMapMidOrder(testMap0);
	myRBMapAddItem(testMap0,&n3);
	printMyRBMapMidOrder(testMap0);
	myRBMapAddItem(testMap0,&n4);
	printMyRBMapMidOrder(testMap0);
	myRBMapAddItem(testMap0,&n5);
	myRBMapAddItem(testMap0,&n6);
	printMyRBMapMidOrder(testMap0);
	myRBMapAddItem(testMap0,&n7);
	printMyRBMapMidOrder(testMap0);
	myRBMapAddItem(testMap0,&n8);
	printMyRBMapMidOrder(testMap0);
	myRBMapAddItem(testMap0,&n9);
	printMyRBMapMidOrder(testMap0);
	myRBMapAddItem(testMap0,&n10);
	printMyRBMapMidOrder(testMap0);
	myRBMapAddItem(testMap0,&n11);
	printMyRBMapMidOrder(testMap0);
	
	/*
	int i = 0;
	for(;i < 100;i++){
		testNode0.iKey = myRandInt(0,10);
		myRBMapAddItem(testMap0,&testNode0);
	}*/
	
	
	//printMyRBMapMidOrder(testMap0);
	
	
	return 0;

}
